package main

import (
	"fmt"
	"gin-client-go/pkg/config"
	"gin-client-go/pkg/router"
	"gin-client-go/pkg/service"
	"github.com/gin-gonic/gin"
	"k8s.io/klog"
)

func main() {
	engine := gin.Default()
	gin.SetMode(gin.DebugMode)
	service.K8s.Init()
	router.InitRouter(engine)
	err := engine.Run(fmt.Sprintf("%s:%d", config.GetString(config.ServerHost), config.GetInt(config.ServerPort)))
	if err != nil {
		klog.Fatal(err)
		return
	}
}

//var kubeConfig *string

//ctx := context.Background()
//if home := homedir.HomeDir(); home != "" {
//	kubeConfig = flag.String("kubeConfig", filepath.Join(home, ".kube", "config"), "absolute path")
//} else {
//	kubeConfig = flag.String("kubeConfig", "", "absolute path to the kubeConfig file")
//}
//flag.Parse()
//config, err := clientcmd.BuildConfigFromFlags("", *kubeConfig)
//if err != nil {
//	klog.Fatal(err)
//	return
//}
//// 从给定的配置创建一个新的k8s客户端。此客户端将会带有认证功能
//clientSet, err := kubernetes.NewForConfig(config)
//if err != nil {
//	klog.Fatal(err)
//	return
//}
//namespaceList, err := clientSet.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})
//if err != nil {
//	klog.Fatal(err)
//	return
//}
//namespaces := namespaceList.Items
//for _, namespace := range namespaces {
//	fmt.Println("Name: ", namespace.Name, ",Status: ", namespace.Status.Phase)
//}
